package com.xmall.controller.admin;

import com.xmall.bean.bo.OrderShipStatus;
import com.xmall.bean.vo.BaseRespVo;
import com.xmall.bean.vo.ListDataVo;
import com.xmall.bean.vo.OrderDetailVO;
import com.xmall.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @RequestMapping("list")
    public BaseRespVo showList(Integer page, Integer limit, String sort, String order, Integer userId, String orderSn, Short orderStatusArray){
        ListDataVo listDataVo = orderService.showList(page, limit, sort, order, userId, orderSn, orderStatusArray);
        return BaseRespVo.ok(listDataVo);
    }
    @RequestMapping("refund")
    public BaseRespVo refundMoney(){
        BaseRespVo baseRespVo = new BaseRespVo();
        baseRespVo.setErrno(621);
        baseRespVo.setErrmsg("订单退款失败");
        return baseRespVo;
    }

    @RequestMapping("detail")
    public BaseRespVo showDetail(Integer id){
        OrderDetailVO orderDetailVO = orderService.showDetail(id);
        return BaseRespVo.ok(orderDetailVO);
    }

    @RequestMapping("reply")
    public BaseRespVo replyInGoods(){
        return BaseRespVo.fail("已回复");
    }

    @RequestMapping("ship")
    public BaseRespVo shipGoodsByOrdesId(@RequestBody OrderShipStatus orderShipStatus){
        orderService.shipGoodsByOrdesId(orderShipStatus);
        return BaseRespVo.ok();
    }
}
